package com.wanmait.recruitment.controller;

import com.wanmait.recruitment.pojo.Degree;
import com.wanmait.recruitment.service.DegreeService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

@Controller
@RequestMapping("manage/degree")
public class DegreeListController {
    @Resource
    private DegreeService degreeService;
    @RequestMapping("list")
    public void list(Model model){
        List<Degree> degrees = degreeService.findAll();
        model.addAttribute("degrees",degrees);
    }
    @RequestMapping("insert")
    @ResponseBody
    public String  insert(String title){
        Degree degree = new Degree();
        degree.setTitle(title);
        degreeService.insert(degree);
        return "ok";
    }
    @RequestMapping("batchDel")
    @ResponseBody
    public void batchDel(String idArr){
        degreeService.batchDel(idArr);
    }
    @RequestMapping("update")
    @ResponseBody
    public void update(Degree degree){
        degreeService.update(degree);
    }
    @RequestMapping("del")
    @ResponseBody
    public void del(String id){
        degreeService.delete(Integer.parseInt(id));
    }
}
